package com.ukao.cashregister.application;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;


import com.nanchen.crashmanager.UncaughtExceptionHandlerImpl;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;
import com.ukao.cashregister.ui.MainActivity;
import com.ukao.cashregister.ui.login.LoginActivity;
import com.ukao.cashregister.utils.CheckUtils;
import com.ukao.cashregister.utils.L;
import com.ukao.cashregister.utils.Utils;

import cn.jiguang.analytics.android.api.JAnalyticsInterface;

/**
 * Created by ukaodev on 2017/5/20.  CrashApplication
 */


public class UKaoApplication  extends Application {

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
        Beta.installTinker();
    }
    @Override
    public void onCreate() {
        super.onCreate();
//       UncaughtExceptionHandlerImpl.getInstance().init(this, BuildConfig.DEBUG, true, 0, LoginActivity.class);
        Utils.init(this);
        JAnalyticsInterface.init(this);
        JAnalyticsInterface.setDebugMode(false);
        checkUpdates();

    }

    private void checkUpdates() {
        // 设置是否开启热更新能力，默认为true
        Beta.enableHotfix = true;
        // 设置是否自动下载补丁
        Beta.canAutoDownloadPatch = true;
        // 设置是否提示用户重启
        Beta.canNotifyUserRestart = true;
        // 设置是否自动合成补丁
        Beta.canAutoPatch = true;
        //Bugly.setIsDevelopmentDevice(getApplicationContext(), true);   开发设备

        Beta.autoCheckUpgrade = CheckUtils.isMIUIDevices()?false:true;
        Beta.initDelay = 100;/*设置启动延时为1s（默认延时3s），APP启动1s后初始化SDK，避免影响APP启动速度*/
        if (!CheckUtils.isMIUIDevices()){
            Beta.canShowUpgradeActs.add(MainActivity.class);
            Beta.canShowUpgradeActs.add(LoginActivity.class);
        }
        Bugly.init(getApplicationContext(), "8711780c19", true);
    }


}
